package com.ssy.lingxi.pay.common;

/**
 * 微信错误信息
 * @author jw.chen
 * @version 2.0.0
 * @date 2020/11/21
 */
public enum WechatErrorEnum {
    BIZERR_NEED_RETRY("BIZERR_NEED_RETRY", "退款业务流程错误，需要商户触发重试来解决"),
    TRADE_OVERDUE("TRADE_OVERDUE", "订单已经超过退款期限"),
    ERROR("ERROR", "业务错误"),
    USER_ACCOUNT_ABNORMAL("USER_ACCOUNT_ABNORMAL", "退款请求失败"),
    INVALID_REQ_TOO_MUCH("INVALID_REQ_TOO_MUCH", "无效请求过多"),
    INVALID_TRANSACTIONID("INVALID_TRANSACTIONID", "无效transaction_id"),
    PARAM_ERROR("PARAM_ERROR", "参数错误"),
    CERT_ERROR("CERT_ERROR", "证书校验错误"),
    REFUND_FEE_MISMATCH("REFUND_FEE_MISMATCH", "订单金额或退款金额与之前请求不一致，请核实后再试"),
    ORDER_NOT_READY("ORDER_NOT_READY", "订单处理中，暂时无法退款，请稍后再试"),
    FREQUENCY_LIMITED("FREQUENCY_LIMITED", "频率限制"),
    INVALID_REQUEST("INVALID_REQUEST", "参数错误"),
    NOAUTH("NOAUTH", "商户无此接口权限"),
    NOTENOUGH("NOTENOUGH", "余额不足"),
    REFUNDNOTEXIST("REFUNDNOTEXIST", "退款订单查询失败"),
    APPID_NOT_EXIST("APPID_NOT_EXIST", "APPID不存在"),
    MCHID_NOT_EXIST("MCHID_NOT_EXIST", "MCHID不存在"),
    APPID_MCHID_NOT_MATCH("APPID_MCHID_NOT_MATCH", "appid和mch_id不匹配"),
    LACK_PARAMS("LACK_PARAMS", "缺少参数"),
    OUT_TRADE_NO_USED("OUT_TRADE_NO_USED", "商户订单号重复"),
    POST_DATA_EMPTY("POST_DATA_EMPTY", "post数据为空"),
    NOT_UTF8("NOT_UTF8", "编码格式错误"),
    ORDERNOTEXIST("ORDERNOTEXIST", "此交易订单号不存在"),
    ORDERPAID("ORDERPAID", "订单已支付"),
    SYSTEMERROR("SYSTEMERROR", "系统错误"),
    ORDERCLOSED("ORDERCLOSED", "订单已关闭"),
    SIGNERROR("SIGNERROR", "签名错误"),
    REQUIRE_POST_METHOD("REQUIRE_POST_METHOD", "请使用post方法"),
    XML_FORMAT_ERROR("XML_FORMAT_ERROR", "XML格式错误");

    private String code;
    private String message;

    WechatErrorEnum(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public String getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public static String getMessage(String code){
        for (WechatErrorEnum e : WechatErrorEnum.values()) {
            if(code.equals(e.getCode())){
                return e.getMessage();
            }
        }
        return "微信支付-未知错误";
    }
}
